<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
<%@ page session="false" %>
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ page pageEncoding="UTF-8" %>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>Manop Service</title>
</head>
<body>
<h1>Car Part</h1>
 
<c:url var="addCarPart" value="/carParts/add.html" />
<c:url var="index" value="/" />

<a href="${addCarPart}">Add Car Part</a> <a href="${index}">-----Back Home------</a>

<table style="border: 1px solid; width: 800px; text-align:center">
 <thead style="background:#fcf">
  <tr>
   <th>Car Part Id</th>
   <th>Brand</th>
   <th>Model</th>
   <th>Name</th>
   <th>Detail</th>
   <th>Price</th>
   <th>Pic.</th>
   <th colspan="3"></th>
  </tr>
 </thead>
 <tbody>
 <c:forEach items="${carParts}" var="carPart">
 <c:url var="editCarPart" value="/carParts/edit.html?id=${carPart.id}" />
<c:url var="deleteCarPart" value="/carParts/delete.html?id=${carPart.id}" />
  <tr>
   <td><c:out value="${carPart.id}" /></td>
   <td><c:out value="${carPart.carModel.carBrand.nameEng}" /></td>
   <td><c:out value="${carPart.carModel.nameEng}" /></td>
   <td><c:out value="${carPart.name}" /></td>
   <td><c:out value="${carPart.detail}" /></td>
   <td><c:out value="${carPart.salePrice}" /></td>
   <td><img src="<c:url value='/resources/images/${carPart.picPath}' />" alt="" /></td>
   <td><a href="${editCarPart}">Edit</a></td>
   <td><a href="${deleteCarPart}">Delete</a></td>
  </tr>
 </c:forEach>
 </tbody>
</table>
 
<c:if test="${empty carParts}">
 There are currently no carParts in the list. <a href="${addCarPart}">Add</a> a Part.
</c:if>
 
</body>
</html>